home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 7 / Eagles_Nest_Mac_Collection_Disc_7.TOAST / PD General / Movie2Snd / Movie2Snd / Read Me < prev    next >
Text File  |  1993-09-10  |  3KB  |  136 lines

  1. Movie2Snd is a very simple application which extracts soundtracks from
  2. QuickTime movies.
  3.  
  4. Drop-launch a movie onto the application (or choose a movie from the open dialog).
  5. You will be prompted for a location for the resulting sound file.  That sound
  6. file is a plain ol' System 7 sound file that can be played by opening
  7. (double clicking).
  8.  
  9. Movie2Snd does all of its work in memory, so you'll need to set the application
  10. memory size large enough to accommodate the sound.  1/2 of the target movie's file
  11. size is a good rule of thumb.  Like I said, this is a very simple program with
  12. practically no user interface.  If an error occurs, it just beeps at you
  13. (QuickTime isn't installed, not enough memory, etc.)
  14.  
  15.  
  16. Version 1.0.1 allows you to preview movies in the open dialog.
  17.  
  18.  
  19. -- Scott Lindsey <wombat@claris.com>
  20.  
  21. MovieSilencer is neither a product of nor is supported by Claris Corporation.
  22. This program is freely distributable.  Here's the source:
  23.  
  24. // (No, this isn't very good example-ware.  It's just a quick hack.)
  25.  
  26. #include <MacHeaders>
  27. #include <Aliases.h>
  28. #include <Folders.h>
  29. #include <Movies.h>
  30. #include <Sound.h>
  31. #include <ImageCompression.h>
  32.  
  33. void MakeSnd(FSSpec *);
  34.  
  35. void main(void)
  36. {
  37.     long    response;
  38.     short     Action, Count;
  39.     OSErr    err;
  40.     AppFile    File;
  41.     FSSpec    fs;
  42.     SFTypeList types = {'MooV'};
  43.  
  44.     if (Gestalt(gestaltQuickTime, &response))
  45.     {
  46.         SysBeep(5);
  47.         ExitToShell();
  48.     }
  49.  
  50.     MaxApplZone();    
  51.     InitGraf(&qd.thePort);
  52.     InitFonts();
  53.     InitWindows();
  54.     InitMenus();
  55.     TEInit();
  56.     InitDialogs(0L);
  57.     InitCursor();
  58.     EnterMovies();
  59.  
  60.     // Yeah, yeah, I oughta use AppleEvents
  61.  
  62.     CountAppFiles(&Action, &Count);
  63.     if (Action == appPrint)
  64.         ExitToShell();
  65.  
  66.     if (Count)
  67.     {
  68.         GetAppFiles(Count, &File);
  69.         FSMakeFSSpec(File.vRefNum, 0L, File.fName, &fs);
  70.     }
  71.     else
  72.     {
  73.         StandardFileReply reply;
  74.         
  75.         StandardGetFilePreview(0L, 1, types, &reply);
  76.         if (!reply.sfGood)
  77.             ExitToShell();
  78.         fs = reply.sfFile;
  79.         Count = 1;
  80.     }
  81.  
  82.     for (;;)
  83.     {
  84.         MakeSnd(&fs);
  85.         if (!--Count)
  86.             break;
  87.         GetAppFiles(Count, &File);
  88.         FSMakeFSSpec(File.vRefNum, 0L, File.fName, &fs);
  89.     }
  90.  
  91.     ExitToShell();
  92. }
  93.  
  94. void MakeSnd(FSSpec *fs)
  95. {
  96.     short refNum, resID = 0;
  97.     Movie movie;
  98.     OSErr err;
  99.     StandardFileReply reply;
  100.     Handle h;
  101.     
  102.     if (err = OpenMovieFile(fs, &refNum, fsRdPerm))
  103.         goto failed;
  104.     if (err = NewMovieFromFile(&movie, refNum, &resID, nil, newMovieActive, nil))
  105.         goto failed;
  106.     err = CloseMovieFile(refNum);
  107.     
  108.     // Maybe make default name based on movie name?
  109.     
  110.     StandardPutFile("\pSave Sound as:", "\pA Sound", &reply);
  111.     
  112.     if (reply.sfGood)
  113.     {
  114.         if (reply.sfReplacing)
  115.             FSpDelete(&reply.sfFile);
  116.          FSpCreateResFile(&reply.sfFile, 'movr', 'sfil', -1);
  117.         refNum = FSpOpenResFile(&reply.sfFile, fsWrPerm);
  118.         h = NewHandle(1024);
  119.         err = PutMovieIntoTypedHandle(movie, 0, 'snd ', h, 0, GetMovieDuration(movie), 0, 0);
  120.         if (!err)
  121.             AddResource(h, 'snd ', 128, reply.sfFile.name);
  122.         CloseResFile(refNum);
  123.     
  124.         if (err)
  125.         {
  126.             FSpDelete(&reply.sfFile);
  127.             goto failed;
  128.         }
  129.     }
  130.     return;
  131.     
  132. failed:
  133.     SysBeep(5);
  134.     return;
  135. }
  136.